import { createWebHistory, createRouter } from 'vue-router'
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import Home from "./components/Home.vue";
import PageHeader from "./components/PageHeader.vue";
import PageFooter from "./components/PageFooter.vue";
import Chat from "./components/Chat.vue";
import Explore from "./components/Explore.vue";
import Draw from "./components/Draw.vue";
import Profile from "./components/Profile.vue";

const routes = [
    { path: '/home', component: Home },
    { path: '/header', component: PageHeader },
    { path: '/footer', component: PageFooter },
    { path: '/chat', component: Chat },
    { path: '/explore', component: Explore },
    { path: '/draw', component: Draw },
    { path: '/profile', component: Profile },
]

const router = createRouter({
    history: createWebHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        if (to.hash) {
            // 如果目标路由包含锚点，滚动到锚点位置
            return {
                el: to.hash,
                behavior: 'smooth', // 平滑滚动
            };
        }
        // 如果没有锚点，返回顶部
        return { top: 0 };
    },
})

createApp(App)
    .use(router)
    .mount('#app')

